using System.Collections;

namespace FakeGameEngine
{
    public abstract class YieldInstruction : IEnumerator
    {
        public abstract bool KeepWaiting { get; }

        public abstract object Current { get; }
        public abstract bool MoveNext();
        public abstract void Reset();
    }

    public class WaitForSeconds : YieldInstruction
    {
        public override bool KeepWaiting => true;

        private readonly float _interval;
        private float _endTime;

        public override object Current => this;

        public WaitForSeconds(float seconds)
        {
            _interval = seconds;
            _endTime = Time.CurrentTime + seconds;
        }

        public override bool MoveNext()
        {
            if (Time.CurrentTime < _endTime)
                return true;
            else
                return false;
        }

        public override void Reset()
        {
            _endTime = Time.CurrentTime + _interval;
        }





    }
}